﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms;
using AndBurn.DDSReader;
using System.IO;

namespace DnPakExplorer.Controls {
	public partial class ItemSlot : UserControl {

		[Category("背景")]
		public Image BackImage {
			get;
			set;
		}

		[Category("背景")]
		public Rectangle BackSrcRect {
			get;
			set;
		}

		[Category("背景")]
		public Rectangle BackDestRect {
			get;
			set;
		}

		[Category("类型")]
		public Image SlotTypeImage {
			get;
			set;
		}


		[Category("类型")]
		public Rectangle SlotTypeSrcRect {
			get;
			set;
		}

		[Category("类型")]
		public Rectangle SlotTypeDestRect {
			get;
			set;
		}

		[Browsable(false)]
		public IUserItem Item {
			get;
			set;
		}


		public ItemSlot() {
			InitializeComponent();
		}

		private void ItemSlot_Paint(object sender, PaintEventArgs e) {
			if (BackImage != null) {
				e.Graphics.DrawImage(BackImage, BackDestRect, BackSrcRect, GraphicsUnit.Pixel);
			} else {
				e.Graphics.DrawRectangle(Pens.Black, ClientRectangle);
			}

			if (SlotTypeImage != null) {
				e.Graphics.DrawImage(SlotTypeImage, SlotTypeDestRect, SlotTypeSrcRect, GraphicsUnit.Pixel);
			}

			if (Item != null) {
				Rectangle dest = new Rectangle(8, 8, 50, 50);
				Util.DrawItemImage(Item.iconId, dest, e.Graphics);
				Util.DrawItemBox(Item.rank, dest, e.Graphics);
				Util.DrawItemTags(Item, this.ClientRectangle, e.Graphics);
			}
		}
	}
}
